

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class CheckTime {
	public static final String START_TIME = "09:00:00";
	public static final String END_TIME = "14:30:00";
	
	public static DateFormat DATE_FORMAT_INTIME = new SimpleDateFormat("HH:mm:ss");
	public static DateFormat DATE_FORMAT_INDATE = new SimpleDateFormat("dd/MM/yyyy");
	
	public static int ONEDAY_TIME_MILIS = 24 * 60 *60 * 1000;
	
	public static void main(String [] args) {
		
		long time = System.currentTimeMillis();
		
		System.out.println(checkNeedToUpdate(time - ONEDAY_TIME_MILIS ) );
		
	}
	
	public static boolean checkNeedToUpdate(long lastUpdateTime) {
		Date lastUpdate = new Date(lastUpdateTime);
		String lastTime = DATE_FORMAT_INTIME.format(lastUpdate);
		String lastDate = DATE_FORMAT_INDATE.format(lastUpdate);
		
		Date date = new Date(System.currentTimeMillis());
		String currentTime = DATE_FORMAT_INTIME.format(date);
		String currentDate = DATE_FORMAT_INDATE.format(date);
		String yesterdayDate = DATE_FORMAT_INDATE.format(new Date(System.currentTimeMillis() - ONEDAY_TIME_MILIS));
		
		boolean overTime = lastTime.compareTo(END_TIME) > 0; 
		boolean inYesterday = yesterdayDate.equals(lastDate);
		boolean inDate = lastDate.equals(currentDate);
		boolean inTime = currentTime.compareTo(START_TIME) >= 0 && currentTime.compareTo(END_TIME) <= 0;
		
		if (inDate && !inTime)
			return false;
		else if (inYesterday && overTime)
			return false;
		else 
			return true;
	}
}
